	.module mmc_sd.c
	.area text(rom, con, rel)
	.dbfile D:\01.Projects\JKElectronics\ATMEGA\CoreModule\sw\examples\lib\mmc_sd.c
	.area data(ram, con, rel)
	.dbfile D:\01.Projects\JKElectronics\ATMEGA\CoreModule\sw\examples\lib\mmc_sd.c
_SD_Type::
	.blkb 1
	.area idata
	.byte 0
	.area data(ram, con, rel)
	.dbfile D:\01.Projects\JKElectronics\ATMEGA\CoreModule\sw\examples\lib\mmc_sd.c
	.dbsym e SD_Type _SD_Type c
	.area lit(rom, con, rel)
L11:
	.byte 0,0
	.byte 0,0
	.byte 0
	.byte 0
	.area text(rom, con, rel)
	.dbfile D:\01.Projects\JKElectronics\ATMEGA\CoreModule\sw\examples\lib\mmc_sd.c
	.dbfunc e SD_Init _SD_Init fc
;           buff -> y+3
;          retry -> R22,R23
;             r1 -> R20
	.even
_SD_Init::
	xcall push_xgsetF00C
	sbiw R28,9
	.dbline -1
	.dbline 18
; 
; 
; #include "hw_config.h"
; #include "mmc_sd.h"
; #include "spi.h"
; #include "uart.h"
; 
; u8 SD_Type = 0; // SD card type
; 
; #define MAX_MMC_INIT_RETRY		2048
; 
; // Initialize SD card
; // Return if successful, it will automatically set the speed to 18Mhz SPI
; // Return value: 0: NO_ERR
; // 1: TIME_OUT
; // 99: NO_CARD
; u8 SD_Init (void)
; {
	.dbline 21
; 	u8 r1; // return value of SD card storage
; 	u16 retry; // used to count out
; 	u8 buff[6] = {0,0,0,0,0};
	ldi R24,<L11
	ldi R25,>L11
	movw R30,R28
	adiw R30,3
	ldi R16,6
	ldi R17,0
	st -y,R31
	st -y,R30
	st -y,R25
	st -y,R24
	xcall asgncblk
	.dbline 46
; 
; #if 0	
; 	// setup I/O ports 
; 
; 	SPI_PORT &= ~((1 << MMC_SCK) | (1 << MMC_MOSI));	// low bits
; 	SPI_PORT |= (1 << MMC_MISO);						// high bits
; 	SPI_DDR  |= (1<<MMC_SCK) | (1<<MMC_MOSI);			// direction
; 
; 
; 
; 
; 
; 	// also need to set SS as output
; #if defined(__AVR_ATmega8__)
; 	// is already set as CS, but we set it again to accomodate for other boards 
; 	SPI_DDR |= (1<<2);
; #else
; 	SPI_DDR |= (1<<0);			// assume it's bit0 (mega128, portB and others)
; #endif
; 
; 	SPCR = (1<<MSTR)|(1<<SPE);	// enable SPI interface
; 	SPSR = 1;					// set double speed	
; #endif
; 
; 	bsp_spi_gpio_init();
	xcall _bsp_spi_gpio_init
	.dbline 47
; 	bsp_spi_init();
	xcall _bsp_spi_init
	.dbline 48
; 	_delay_ms(5);
	ldi R16,5
	ldi R17,0
	xcall __delay_ms
	.dbline 49
; 	bsp_set_spi_speed(SPI_SPEED_LOW);
	ldi R16,1
	xcall _bsp_set_spi_speed
	.dbline 50
; 	_delay_ms(5);
	ldi R16,5
	ldi R17,0
	xcall __delay_ms
	.dbline 52
; 
; 	MMC_CS_PORT |= (1 << MMC_CS);	// Initial level is high	
	sbi 0x18,0
	.dbline 53
; 	MMC_CS_DIR  |= (1 << MMC_CS);	// Direction is output	
	sbi 0x17,0
	.dbline 55
; 
; 	MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 58
; 
; 	// start transmission
; 	bsp_readwritebyte_spi(0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 61
; 
; 
; 	if (SD_Idle_Sta()) 
	xcall _SD_Idle_Sta
	tst R16
	breq L12
X0:
	.dbline 62
; 	{
	.dbline 66
; #ifdef MMC_DBG
; 		usart0_puts("Idle mode failed\r\n");
; #endif		
; 		return 1; 	// 1 set out to return to the idle mode failed
	ldi R16,1
	xjmp L10
L12:
	.dbline 71
; 	}
; 
; 	//----------------- SD card is reset to the idle end of the -----------------
; 	// Get the SD card version
; 	MSD_CS_ENABLE();
	cbi 0x18,0
	.dbline 73
; 
; 	r1 = SD_SendCommand_NoDeassert (8, 0x1aa, 0x87);
	ldi R24,135
	std y+2,R24
	ldi R24,170
	ldi R25,1
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,8
	xcall _SD_SendCommand_NoDeassert
	mov R20,R16
	.dbline 76
; 
; 	// If the version information is the v1.0 version of the card, ie r1 = 0x05, then the following initialization
; 	if (r1 == 0x05)
	cpi R16,5
	breq X18
	xjmp L14
X18:
X1:
	.dbline 77
; 	{
	.dbline 79
; 		// Set the card type to SDV1.0, if the latter is detected as the MMC card, and then modified to MMC
; 		SD_Type = SD_TYPE_V1;
	ldi R24,1
	sts _SD_Type,R24
	.dbline 82
; 		// If the V1.0 card, CMD8 instruction did not follow-up data
; 		// Set chip select high end of the second order
; 		MSD_CS_ENABLE();
	cbi 0x18,0
	.dbline 85
; 
; 		// Multiple 8 CLK, so that the end of follow-up operation SD
; 		bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 91
; 
; 		//----------------- SD card, MMC card initialization -----------------
; 		// Initialize command CMD55 + ACMD41 Card
; 		// If there is response, that is the SD card, and the initialization is complete
; 		// No response, that is the MMC card, the corresponding additional initialization
; 		retry = 0;
	clr R22
	clr R23
L16:
	.dbline 93
; 		do
; 		{
	.dbline 95
; 			// Starting CMD55, should return 0x01; or wrong
; 			r1 = SD_SendCommand (CMD55, 0, 0);
	clr R2
	std y+2,R2
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,55
	xcall _SD_SendCommand
	mov R10,R16
	mov R20,R10
	.dbline 96
; 			if (r1 == 0XFF) return r1; // if not 0xff, then sent to
	cpi R16,255
	brne L19
X2:
	.dbline 96
	xjmp L10
L19:
	.dbline 99
; 
; 			// Get the correct response, sent ACMD41, the return value should be 0x00, otherwise retry 200
; 			r1 = SD_SendCommand (ACMD41, 0, 0);
	clr R2
	std y+2,R2
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,41
	xcall _SD_SendCommand
	mov R10,R16
	mov R20,R10
	.dbline 101
; 
; 			retry++;
	subi R22,255  ; offset = 1
	sbci R23,255
	.dbline 102
; 	    } while ((r1 != 0x00) && (retry <MAX_MMC_INIT_RETRY));
L17:
	.dbline 102
	tst R20
	breq L21
X3:
	cpi R22,0
	ldi R30,8
	cpc R23,R30
	brlo L16
X4:
L21:
	.dbline 107
; 		
; 	    // Determine the correct response is the time-out or
; 	    // If response: is the SD card; did not respond: is the MMC card
; 	    //---------- MMC card for additional initialization started ------------
; 	    if (retry == MAX_MMC_INIT_RETRY)
	cpi R22,0
	ldi R30,8
	cpc R23,R30
	brne L22
X5:
	.dbline 108
; 	    {
	.dbline 109
; 			retry = 0;
	clr R22
	clr R23
L24:
	.dbline 112
; 			// Initialize command to send MMC card (not tested)
; 			do
; 			{
	.dbline 113
; 			    r1 = SD_SendCommand (1,0,0);
	clr R2
	std y+2,R2
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,1
	xcall _SD_SendCommand
	mov R10,R16
	mov R20,R10
	.dbline 114
; 			    retry++;
	subi R22,255  ; offset = 1
	sbci R23,255
	.dbline 115
; 			} while ((r1 != 0x00) && (retry <MAX_MMC_INIT_RETRY));
L25:
	.dbline 115
	tst R20
	breq L27
X6:
	cpi R22,0
	ldi R30,8
	cpc R23,R30
	brlo L24
X7:
L27:
	.dbline 117
; 
; 			if (retry == MAX_MMC_INIT_RETRY) 
	cpi R22,0
	ldi R30,8
	cpc R23,R30
	brne L28
X8:
	.dbline 118
; 			{
	.dbline 122
; #ifdef MMC_DBG
; 				usart0_puts("Initialization timed out\r\n");
; #endif						
; 				return 1; // MMC card initialization timed out
	ldi R16,1
	xjmp L10
L28:
	.dbline 126
; 			}
; 
; 			// Write card type
; 			SD_Type = SD_TYPE_MMC;
	clr R2
	sts _SD_Type,R2
	.dbline 127
; 	    }
L22:
	.dbline 131
; 		
; 	    //---------- MMC card for additional initialization end ------------
; 	    // Set SPI high-speed mode
; 	    bsp_set_spi_speed(SPI_SPEED_HIGH);
	clr R16
	xcall _bsp_set_spi_speed
	.dbline 132
; 	    bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 135
; 		
; 	    // Disable CRC check
; 	    r1 = SD_SendCommand (CMD59, 0, 0x95);
	ldi R24,149
	std y+2,R24
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,59
	xcall _SD_SendCommand
	mov R10,R16
	mov R20,R10
	.dbline 136
; 	    if (r1 != 0x00) 
	tst R16
	breq L30
X9:
	.dbline 137
; 	    {
	.dbline 141
; #ifdef MMC_DBG
; 			usart0_puts("command error 1\r\n");
; #endif		    
; 			return r1; // command error, returns r1
	xjmp L10
L30:
	.dbline 145
; 	    }
; 	    
; 	    // Set Sector Size
; 	    r1 = SD_SendCommand (CMD16, 512, 0x95);
	ldi R24,149
	std y+2,R24
	ldi R24,0
	ldi R25,2
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,16
	xcall _SD_SendCommand
	mov R10,R16
	mov R20,R10
	.dbline 146
; 	    if (r1 != 0x00) 
	tst R16
	brne X19
	xjmp L15
X19:
X10:
	.dbline 147
; 	    	{
	.dbline 151
; #ifdef MMC_DBG
; 			usart0_puts("command error 2\r\n");
; #endif		    	    	
; 			return r1; // command error, returns r1
	xjmp L10
L14:
	.dbline 160
; 	    	}
; 	    //----------------- SD card, MMC card initialization ended -----------------
; 
; 	} 
; 	// SD Card for the V1.0 version of the initialization is complete
; 	
; 	// Here is the card initialization V2.0
; 	// Which need to read the OCR data, with a diagnosis or SD2.0HC Card SD2.0
; 	else if (r1 == 0x01)
	cpi R20,1
	breq X20
	xjmp L34
X20:
X11:
	.dbline 161
; 	{
	.dbline 163
; 	    // V2.0 card, CMD8 command returns 4 bytes of data, and then to skip the end of the command
; 	    buff[0] = bsp_readwritebyte_spi (0xFF); // should be 0x00
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	std y+3,R10
	.dbline 164
; 	    buff[1] = bsp_readwritebyte_spi (0xFF); // should be 0x00
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	std y+4,R10
	.dbline 165
; 	    buff[2] = bsp_readwritebyte_spi (0xFF); // should be 0x01
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	std y+5,R10
	.dbline 166
; 	    buff[3] = bsp_readwritebyte_spi (0xFF); // should be 0xAA
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	std y+6,R10
	.dbline 168
; 	    
; 	    MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 169
; 	    bsp_readwritebyte_spi (0xFF); // the next 8 clocks
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 172
; 	    // Determine whether the card supports a voltage range of 2.7V-3.6V
; 	    // if (buff [2] == 0x01 && buff [3] == 0xAA) // do not judge, let the cards to support more
; 	    {
	.dbline 173
; 			retry = 0;
	clr R22
	clr R23
L39:
	.dbline 176
; 			// Initialize command CMD55 + ACMD41 Card
; 			do
; 			{
	.dbline 177
; 				r1 = SD_SendCommand (CMD55, 0, 0);
	clr R2
	std y+2,R2
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,55
	xcall _SD_SendCommand
	mov R10,R16
	mov R20,R10
	.dbline 179
; 
; 				if (r1 == 0xff) 
	cpi R16,255
	brne L42
X12:
	.dbline 180
; 			    	{
	.dbline 184
; #ifdef MMC_DBG
; 					usart0_puts("command error a\r\n");
; #endif		    	    	
; 					return r1;
	xjmp L10
L42:
	.dbline 196
; 			    	}
; #if 0				
; 				if (r1 != 0x01) 
; 			    	{
; #ifdef MMC_DBG
; 					usart0_puts("command error 3\r\n");
; #endif		    	    	
; 					return r1;
; 			    	}
; #endif				
; 
; 				r1 = SD_SendCommand (ACMD41, 0x40000000, 0);
	clr R2
	std y+2,R2
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,64
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,41
	xcall _SD_SendCommand
	mov R10,R16
	mov R20,R10
	.dbline 197
; 				if (retry> MAX_MMC_INIT_RETRY) 
	ldi R24,2048
	ldi R25,8
	cp R24,R22
	cpc R25,R23
	brsh L44
X13:
	.dbline 198
; 			    	{
	.dbline 202
; #ifdef MMC_DBG
; 					usart0_puts("Initialized time out 2\r\n");
; #endif		    	    	
; 					return r1; // timeout return status r1
	xjmp L10
L44:
	.dbline 205
; 			    	}					
; 
; 				retry++;
	subi R22,255  ; offset = 1
	sbci R23,255
	.dbline 207
; 					
; 			} while ((r1 != 0x00) && (retry <MAX_MMC_INIT_RETRY));
L40:
	.dbline 207
	tst R20
	breq L46
X14:
	cpi R22,0
	ldi R30,8
	cpc R23,R30
	brlo L39
X15:
L46:
	.dbline 212
; 			
; 			// Initialize command to send to complete, the next access to OCR information
; 			// SD2.0 card identification since version 
; 			//----------- -----------
; 			r1 = SD_SendCommand_NoDeassert (CMD58, 0, 0);
	clr R2
	std y+2,R2
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,58
	xcall _SD_SendCommand_NoDeassert
	mov R10,R16
	mov R20,R10
	.dbline 213
; 			if (r1 != 0x00)
	tst R16
	breq L47
X16:
	.dbline 214
; 			{
	.dbline 215
; 				MSD_CS_DISABLE(); // release chip select signal SD
	sbi 0x18,0
	.dbline 219
; #ifdef MMC_DBG
; 				usart0_puts("command does not return the correct response\r\n");
; #endif					
; 				return r1; // If the command does not return the correct response, direct withdrawal, return response
	xjmp L10
L47:
	.dbline 222
; 			} // Read OCR command is issued, followed by 4 bytes of OCR information
; 
; 			buff [0] = bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	std y+3,R10
	.dbline 223
; 			buff [1] = bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	std y+4,R10
	.dbline 224
; 			buff [2] = bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	std y+5,R10
	.dbline 225
; 			buff [3] = bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	std y+6,R10
	.dbline 228
; 
; 			// OCR to receive complete set of high chip select
; 			MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 229
; 			bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 233
; 
; 			// Check the received OCR in bit30-bit (CCS), was identified as SD2.0 SDHC
; 			// If the CCS = 1: SDHC CCS = 0: SD2.0
; 			if (buff [0] & 0x40) 
	ldd R2,y+3
	sbrs R2,6
	rjmp L52
X17:
	.dbline 234
; 				SD_Type = SD_TYPE_V2HC; // Check the CCS
	ldi R24,4
	sts _SD_Type,R24
	xjmp L53
L52:
	.dbline 236
; 			else 
; 				SD_Type = SD_TYPE_V2;
	ldi R24,2
	sts _SD_Type,R24
L53:
	.dbline 239
; 			//----------- Identification card version of SD2.0 end -----------
; 			// Set SPI high-speed mode
; 			bsp_set_spi_speed(SPI_SPEED_HIGH);
	clr R16
	xcall _bsp_set_spi_speed
	.dbline 240
; 	    }
	.dbline 241
; 	}
L34:
L15:
	.dbline 242
; 	return r1;
	mov R16,R20
	.dbline -2
L10:
	.dbline 0 ; func end
	adiw R28,9
	xjmp pop_xgsetF00C
	.dbsym l buff 3 A[6:6]c
	.dbsym r retry 22 i
	.dbsym r r1 20 c
	.dbend
	.dbfunc e SD_GetResponse _SD_GetResponse fc
;          Count -> R20,R21
;       Response -> R10
	.even
_SD_GetResponse::
	xcall push_xgset300C
	mov R10,R16
	.dbline -1
	.dbline 251
; 	
; }
; 
; // Wait for response to SD card
; // Response: to get the feedback value
; // Return value: 0, success has been the value of the response
; // Otherwise, get the value of failure to respond
; u8 SD_GetResponse (u8 Response)
; {
	.dbline 252
; 	u16 Count = 0xFFF; // wait times
	ldi R20,4095
	ldi R21,15
	xjmp L56
L55:
	.dbline 255
; 
; 	while ((bsp_readwritebyte_spi (0XFF) != Response) && Count) 
; 		Count--; // waiting to get an accurate response
	subi R20,1
	sbci R21,0
L56:
	.dbline 254
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	cp R16,R10
	breq L58
X21:
	cpi R20,0
	cpc R20,R21
	brne L55
X22:
L58:
	.dbline 257
; 
; 	if (Count == 0) 
	cpi R20,0
	cpc R20,R21
	brne L59
X23:
	.dbline 258
; 		return MSD_RESPONSE_FAILURE; // get a response failure
	ldi R16,255
	xjmp L54
L59:
	.dbline 260
; 	else 
; 		return MSD_RESPONSE_NO_ERROR; // correct response
	clr R16
	.dbline -2
L54:
	.dbline 0 ; func end
	xjmp pop_xgset300C
	.dbsym r Count 20 i
	.dbsym r Response 10 c
	.dbend
	.dbfunc e SD_WaitDataReady _SD_WaitDataReady fc
;             r1 -> R20
;          retry -> y+0
	.even
_SD_WaitDataReady::
	xcall push_xgsetF000
	sbiw R28,4
	.dbline -1
	.dbline 267
; }
; 
; // Wait for write to complete the SD card
; // Return value: 0 success;
; // Other, error codes;
; u8 SD_WaitDataReady (void)
; {
	.dbline 268
; 	u8 r1 = MSD_DATA_OTHER_ERROR;
	ldi R20,255
	.dbline 270
; 	u32 retry;
; 	retry = 0;
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R24
	std y+1,R25
	std y+2,R26
	std y+3,R27
L62:
	.dbline 272
; 	do
; 	{
	.dbline 273
;        	 r1 = bsp_readwritebyte_spi (0xFF) &0X1F; // read response
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R20,R16
	andi R20,31
	.dbline 275
;        	 
;         	if (retry == 0xfffe) 
	ldi R24,254
	ldi R25,255
	ldi R26,0
	ldi R27,0
	ldd R2,y+0
	ldd R3,y+1
	ldd R4,y+2
	ldd R5,y+3
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brne L65
X24:
	.dbline 276
; 			return 1;
	ldi R16,1
	xjmp L61
L65:
	.dbline 278
; 			
; 		retry++;
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	ldd R2,y+0
	ldd R3,y+1
	ldd R4,y+2
	ldd R5,y+3
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	.dbline 280
; 		
; 		switch (r1)
	mov R22,R20
	clr R23
	cpi R22,5
	ldi R30,0
	cpc R23,R30
	breq L70
X25:
	cpi R22,5
	ldi R30,0
	cpc R23,R30
	brlt L67
X26:
L73:
	cpi R22,11
	ldi R30,0
	cpc R23,R30
	breq L71
X27:
	cpi R22,13
	ldi R30,0
	cpc R23,R30
	breq L72
X28:
	xjmp L67
L70:
	.dbline 283
; 		{
; 		case MSD_DATA_OK: // correct the data reception
; 			r1 = MSD_DATA_OK;
	ldi R20,5
	.dbline 284
; 			break;
	xjmp L68
L71:
	.dbline 286
; 		case MSD_DATA_CRC_ERROR: // CRC checksum error
; 			return MSD_DATA_CRC_ERROR;
	ldi R16,11
	xjmp L61
L72:
	.dbline 288
; 		case MSD_DATA_WRITE_ERROR: // Data write error
; 			return MSD_DATA_WRITE_ERROR;
	ldi R16,13
	xjmp L61
L67:
	.dbline 290
; 		default: // Unknown error
; 			r1 = MSD_DATA_OTHER_ERROR;
	ldi R20,255
	.dbline 291
; 		break;
L68:
	.dbline 293
; 		}
; 	} while (r1 == MSD_DATA_OTHER_ERROR); // data errors have been waiting for
L63:
	.dbline 293
	cpi R20,255
	brne X32
	xjmp L62
X32:
X29:
	.dbline 295
; 	
; 	retry = 0;
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R24
	std y+1,R25
	std y+2,R26
	std y+3,R27
	xjmp L75
L74:
	.dbline 297
; 	while (bsp_readwritebyte_spi (0XFF) == 0) // read data to 0, the data has not yet completed writing
; 	{
	.dbline 298
; 		retry++;
	ldi R24,1
	ldi R25,0
	ldi R26,0
	ldi R27,0
	ldd R2,y+0
	ldd R3,y+1
	ldd R4,y+2
	ldd R5,y+3
	add R2,R24
	adc R3,R25
	adc R4,R26
	adc R5,R27
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	.dbline 301
; 		
; 		// Delay_us (10); // SD card write takes a long time to wait
; 		if (retry >= 0XFFFFFFFE) 
	ldi R24,254
	ldi R25,255
	ldi R26,255
	ldi R27,255
	ldd R2,y+0
	ldd R3,y+1
	ldd R4,y+2
	ldd R5,y+3
	cp R2,R24
	cpc R3,R25
	cpc R4,R26
	cpc R5,R27
	brlo L77
X30:
	.dbline 302
; 			return 0XFF; // Wait failed
	ldi R16,255
	xjmp L61
L77:
	.dbline 303
; 	};
L75:
	.dbline 296
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	tst R16
	breq L74
X31:
	.dbline 303
	.dbline 304
; 	return 0; // success
	clr R16
	.dbline -2
L61:
	.dbline 0 ; func end
	adiw R28,4
	xjmp pop_xgsetF000
	.dbsym r r1 20 c
	.dbsym l retry 0 l
	.dbend
	.dbfunc e SD_SendCommand _SD_SendCommand fc
;             r1 -> R10
;          Retry -> R12
;            crc -> y+10
;            arg -> y+6
;            cmd -> R20
	.even
_SD_SendCommand::
	st -y,r19
	st -y,r18
	xcall push_xgset303C
	mov R20,R16
	.dbline -1
	.dbline 314
; }
; 
; 
; // Send a command to the SD card
; // Input: u8 cmd command
; // U32 arg command arguments
; // U8 crc crc checksum
; // Return value: SD card, the response returned
; u8 SD_SendCommand (u8 cmd, u32 arg, u8 crc)
; {
	.dbline 316
; 	u8 r1;
; 	u8 Retry = 0;
	clr R12
	.dbline 319
; 
; 	// Close the chip select
; 	MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 321
; 	
; 	bsp_readwritebyte_spi (0xff); // high-speed write command delay
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 322
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 323
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 326
; 	
; 	// Chip select low-end set, select the SD card
; 	MSD_CS_ENABLE();
	cbi 0x18,0
	.dbline 329
; 	
; 	// Send
; 	bsp_readwritebyte_spi (cmd | 0x40); // write command, respectively,
	mov R16,R20
	ori R16,64
	xcall _bsp_readwritebyte_spi
	.dbline 330
; 	bsp_readwritebyte_spi (arg>> 24);
	ldi R24,24
	ldi R25,0
	ldd R16,y+6
	ldd R17,y+7
	ldd R18,y+8
	ldd R19,y+9
	st -y,R24
	xcall lsr32
	xcall _bsp_readwritebyte_spi
	.dbline 331
; 	bsp_readwritebyte_spi (arg>> 16);
	ldd R2,y+6
	ldd R3,y+7
	ldd R4,y+8
	ldd R5,y+9
	movw R2,R4
	clr R4
	clr R5
	mov R16,R2
	xcall _bsp_readwritebyte_spi
	.dbline 332
; 	bsp_readwritebyte_spi (arg>> 8);
	ldi R24,8
	ldi R25,0
	ldd R16,y+6
	ldd R17,y+7
	ldd R18,y+8
	ldd R19,y+9
	st -y,R24
	xcall lsr32
	xcall _bsp_readwritebyte_spi
	.dbline 333
; 	bsp_readwritebyte_spi (arg);
	ldd R16,y+6
	xcall _bsp_readwritebyte_spi
	.dbline 334
; 	bsp_readwritebyte_spi (crc);
	ldd R16,y+10
	xcall _bsp_readwritebyte_spi
	xjmp L81
L80:
	.dbline 338
; 	
; 	// Wait for a response, or time-out exit
; 	while ((r1 = bsp_readwritebyte_spi (0xFF)) == 0xFF)
; 	{
	.dbline 339
; 		Retry++;
	inc R12
	.dbline 340
; 		if (Retry> 200) 
	ldi R24,200
	cp R24,R12
	brsh L83
X33:
	.dbline 341
; 			break;
	xjmp L82
L83:
	.dbline 342
; 	}
L81:
	.dbline 337
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	cpi R16,255
	breq L80
X34:
L82:
	.dbline 345
; 	
; 	// Close the chip select
; 	MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 348
; 	
; 	// Additional 8 on the bus clock, so that SD card to complete the remaining work
; 	bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 351
; 	
; 	// Return status values
; 	return r1;
	mov R16,R10
	.dbline -2
L79:
	.dbline 0 ; func end
	xcall pop_xgset303C
	adiw R28,2
	ret
	.dbsym r r1 10 c
	.dbsym r Retry 12 c
	.dbsym l crc 10 c
	.dbsym l arg 6 l
	.dbsym r cmd 20 c
	.dbend
	.dbfunc e SD_SendCommand_NoDeassert _SD_SendCommand_NoDeassert fc
;             r1 -> R10
;          Retry -> R12
;            crc -> y+10
;            arg -> y+6
;            cmd -> R20
	.even
_SD_SendCommand_NoDeassert::
	st -y,r19
	st -y,r18
	xcall push_xgset303C
	mov R20,R16
	.dbline -1
	.dbline 361
; 	
; }
; 
; // Send a command to the SD card (the end is yet to chip select, there came the follow-up data)
; // Input: u8 cmd command
; // U32 arg command arguments
; // U8 crc crc checksum
; // Return value: SD card, the response returned
; u8 SD_SendCommand_NoDeassert (u8 cmd, u32 arg, u8 crc)
; {
	.dbline 362
; 	u8 Retry = 0;
	clr R12
	.dbline 365
; 	u8 r1;
; 	
; 	bsp_readwritebyte_spi (0xff); // high-speed write command delay
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 366
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 369
; 
; 	// chip select low-end set, select the SD card
; 	MSD_CS_ENABLE(); 
	cbi 0x18,0
	.dbline 372
; 	
; 	// Send
; 	bsp_readwritebyte_spi (cmd | 0x40); // write command, respectively,
	mov R16,R20
	ori R16,64
	xcall _bsp_readwritebyte_spi
	.dbline 373
; 	bsp_readwritebyte_spi (arg>> 24);
	ldi R24,24
	ldi R25,0
	ldd R16,y+6
	ldd R17,y+7
	ldd R18,y+8
	ldd R19,y+9
	st -y,R24
	xcall lsr32
	xcall _bsp_readwritebyte_spi
	.dbline 374
; 	bsp_readwritebyte_spi (arg>> 16);
	ldd R2,y+6
	ldd R3,y+7
	ldd R4,y+8
	ldd R5,y+9
	movw R2,R4
	clr R4
	clr R5
	mov R16,R2
	xcall _bsp_readwritebyte_spi
	.dbline 375
; 	bsp_readwritebyte_spi (arg>> 8);
	ldi R24,8
	ldi R25,0
	ldd R16,y+6
	ldd R17,y+7
	ldd R18,y+8
	ldd R19,y+9
	st -y,R24
	xcall lsr32
	xcall _bsp_readwritebyte_spi
	.dbline 376
; 	bsp_readwritebyte_spi (arg);
	ldd R16,y+6
	xcall _bsp_readwritebyte_spi
	.dbline 377
; 	bsp_readwritebyte_spi (crc);
	ldd R16,y+10
	xcall _bsp_readwritebyte_spi
	xjmp L87
L86:
	.dbline 381
; 	
; 	// Wait for a response, or time-out exit
; 	while ((r1 = bsp_readwritebyte_spi (0xFF)) == 0xFF)
; 	{
	.dbline 382
; 	    Retry++;
	inc R12
	.dbline 383
; 	    if (Retry> 200) 
	ldi R24,200
	cp R24,R12
	brsh L89
X35:
	.dbline 384
; 			break;
	xjmp L88
L89:
	.dbline 385
; 	}
L87:
	.dbline 380
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	cpi R16,255
	breq L86
X36:
L88:
	.dbline 388
; 	
; 	// Return the response value
; 	return r1;
	mov R16,R10
	.dbline -2
L85:
	.dbline 0 ; func end
	xcall pop_xgset303C
	adiw R28,2
	ret
	.dbsym r r1 10 c
	.dbsym r Retry 12 c
	.dbsym l crc 10 c
	.dbsym l arg 6 l
	.dbsym r cmd 20 c
	.dbend
	.dbfunc e SD_Idle_Sta _SD_Idle_Sta fc
;             r1 -> R22
;          retry -> R20
;              i -> R20,R21
	.even
_SD_Idle_Sta::
	xcall push_xgsetF000
	sbiw R28,3
	.dbline -1
	.dbline 395
; }
; 
; // Set the SD card into suspend mode
; // Return value: 0, successfully set
; // 1, setup failed
; u8 SD_Idle_Sta (void)
; {
	.dbline 400
; 	u16 i;
; 	u8 r1;
; 	u8 retry;
; 
; 	for (i = 0; i <0xf00; i++);// pure delay, waiting for complete power-SD card
	clr R20
	clr R21
	xjmp L95
L92:
	.dbline 400
L93:
	.dbline 400
	subi R20,255  ; offset = 1
	sbci R21,255
L95:
	.dbline 400
	cpi R20,0
	ldi R30,15
	cpc R21,R30
	brlo L92
X37:
	.dbline 403
; 
; 	// Should generate> 74 pulses, so that SD card to complete their initialization
; 	for (i = 0; i <10; i++) bsp_readwritebyte_spi (0xFF);
	clr R20
	clr R21
	xjmp L99
L96:
	.dbline 403
	ldi R16,255
	xcall _bsp_readwritebyte_spi
L97:
	.dbline 403
	subi R20,255  ; offset = 1
	sbci R21,255
L99:
	.dbline 403
	cpi R20,10
	ldi R30,0
	cpc R21,R30
	brlo L96
X38:
	.dbline 408
; 
; 	//----------------- SD card is reset to the idle start -----------------
; 	// Loop continuously sending CMD0, until the SD card back 0x01, enter the IDLE state
; 	// Timeout then exit
; 	retry = 0;
	clr R20
L100:
	.dbline 410
; 	do
; 	{
	.dbline 412
; 		// Send CMD0, so that SD card into the IDLE state
; 		r1 = SD_SendCommand (CMD0, 0, 0x95);
	ldi R24,149
	std y+2,R24
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	clr R16
	xcall _SD_SendCommand
	mov R22,R16
	.dbline 413
; 		retry++;
	inc R20
	.dbline 414
; 	} while ((r1 != 0x01) && (retry <200));
L101:
	.dbline 414
	cpi R22,1
	breq L103
X39:
	cpi R20,200
	brlo L100
X40:
L103:
	.dbline 417
; 
; 	// Exit the loop, check reason: Initialization successful? or try out?
; 	if (retry == 200) return 1; // fail
	cpi R20,200
	brne L104
X41:
	.dbline 417
	ldi R16,1
	xjmp L91
L104:
	.dbline 419
; 
; 	return 0; // success
	clr R16
	.dbline -2
L91:
	.dbline 0 ; func end
	adiw R28,3
	xjmp pop_xgsetF000
	.dbsym r r1 22 c
	.dbsym r retry 20 c
	.dbsym r i 20 i
	.dbend
	.dbfunc e SD_ReceiveData _SD_ReceiveData fc
;        release -> y+6
;            len -> R10,R11
;           data -> R20,R21
	.even
_SD_ReceiveData::
	xcall push_xgsetF00C
	movw R10,R18
	movw R20,R16
	.dbline -1
	.dbline 430
; }
; 
; 
; // Read back from the SD card in the specified length of data placed in a given position
; // Input: u8 * data (read back the data storage memory> len)
; // U16 len (data length)
; // U8 release (whether to release the bus after transfer CS is set high 0: do not release 1: Release)
; // Return value: 0: NO_ERR
; // Other: Error Message
; u8 SD_ReceiveData (u8 * data, u16 len, u8 release)
; {
	.dbline 432
; 	// Start the first transfer
; 	MSD_CS_ENABLE();
	cbi 0x18,0
	.dbline 433
; 	if (SD_GetResponse (0xFE)) // wait for data sent back to the starting SD card token 0xFE
	ldi R16,254
	xcall _SD_GetResponse
	tst R16
	breq L110
X42:
	.dbline 434
; 	{
	.dbline 435
; 		MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 436
; 		return 1;
	ldi R16,1
	xjmp L106
L109:
	.dbline 440
; 	}
; 	
; 	while (len--) // Start receiving data
; 	{
	.dbline 441
; 		*data = bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	movw R30,R20
	std z+0,R16
	.dbline 442
; 		data++;
	subi R20,255  ; offset = 1
	sbci R21,255
	.dbline 443
; 	}
L110:
	.dbline 439
	movw R22,R10
	movw R24,R22
	sbiw R24,1
	movw R10,R24
	cpi R22,0
	cpc R22,R23
	brne L109
X43:
	.dbline 446
; 	
; 	// Here are two pseudo-CRC (dummy CRC)
; 	bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 447
; 	bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 448
; 	if (release == RELEASE) // demand the release of the bus, the CS is set high
	ldd R24,y+6
	cpi R24,1
	brne L112
X44:
	.dbline 449
; 	{
	.dbline 450
; 		MSD_CS_DISABLE(); // end of transmission
	sbi 0x18,0
	.dbline 451
; 		bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 452
; 	}
L112:
	.dbline 453
; 	return 0;
	clr R16
	.dbline -2
L106:
	.dbline 0 ; func end
	xjmp pop_xgsetF00C
	.dbsym l release 6 c
	.dbsym r len 10 i
	.dbsym r data 20 pc
	.dbend
	.dbfunc e SD_GetCID _SD_GetCID fc
;             r1 -> R12
;       cid_data -> R10,R11
	.even
_SD_GetCID::
	xcall push_xgset003C
	movw R10,R16
	sbiw R28,3
	.dbline -1
	.dbline 462
; }
; 
; // Get the SD card CID information, including manufacturer information
; // Input: u8 * cid_data (CID stored in the memory, at least 16Byte)
; // Return value: 0: NO_ERR
; // 1: TIME_OUT
; // Other: Error Message
; u8 SD_GetCID (u8 * cid_data)
; {
	.dbline 466
; 	u8 r1;
; 	
; 	// Send CMD10 command, read CID
; 	r1 = SD_SendCommand(CMD10,0,0xff);
	ldi R24,255
	std y+2,R24
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,10
	xcall _SD_SendCommand
	mov R12,R16
	.dbline 468
; 	
; 	if (r1 != 0x00) 
	tst R16
	breq L115
X45:
	.dbline 469
; 		return r1; // do not return the correct answer, then exit, error
	xjmp L114
L115:
	.dbline 471
; 		
; 	SD_ReceiveData (cid_data, 16, RELEASE); // 16 bytes of data received
	ldi R24,1
	std y+0,R24
	ldi R18,16
	ldi R19,0
	movw R16,R10
	xcall _SD_ReceiveData
	.dbline 472
; 	return 0;
	clr R16
	.dbline -2
L114:
	.dbline 0 ; func end
	adiw R28,3
	xjmp pop_xgset003C
	.dbsym r r1 12 c
	.dbsym r cid_data 10 pc
	.dbend
	.dbfunc e SD_GetCSD _SD_GetCSD fc
;             r1 -> R12
;       csd_data -> R10,R11
	.even
_SD_GetCSD::
	xcall push_xgset003C
	movw R10,R16
	sbiw R28,3
	.dbline -1
	.dbline 481
; }
; 
; // Get the SD card, CSD, including the capacity and speed of information
; // Input: u8 * cid_data (CID stored in the memory, at least 16Byte)
; // Return value: 0: NO_ERR
; // 1: TIME_OUT
; // Other: Error Message
; u8 SD_GetCSD (u8 *csd_data)
; {
	.dbline 484
; 	u8 r1;
; 	
; 	r1 = SD_SendCommand(CMD9, 0, 0xff); // send CMD9 command, read CSD
	ldi R24,255
	std y+2,R24
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,9
	xcall _SD_SendCommand
	mov R12,R16
	.dbline 486
; 	
; 	if (r1) 
	tst R16
	breq L118
X46:
	.dbline 487
; 	{
	.dbline 491
; #ifdef MMC_DBG
; 		usart0_puts("SD_GetCSD command error");
; #endif	
; 		return r1; // do not return the correct answer, then exit, error
	xjmp L117
L118:
	.dbline 494
; 	}
; 		
; 	SD_ReceiveData (csd_data, 16, RELEASE); // 16 bytes of data received
	ldi R24,1
	std y+0,R24
	ldi R18,16
	ldi R19,0
	movw R16,R10
	xcall _SD_ReceiveData
	.dbline 496
; 	
; 	return 0;
	clr R16
	.dbline -2
L117:
	.dbline 0 ; func end
	adiw R28,3
	xjmp pop_xgset003C
	.dbsym r r1 12 c
	.dbsym r csd_data 10 pc
	.dbend
	.dbfunc e SD_GetCapacity _SD_GetCapacity fl
;       Capacity -> y+28
;            csd -> y+12
;           temp -> y+8
;             r1 -> y+4
;              i -> y+0
	.even
_SD_GetCapacity::
	xcall push_xgsetF000
	sbiw R28,32
	.dbline -1
	.dbline 503
; }
; 
; // Get the SD card capacity (bytes)
; // Return value: 0: take capacity error
; // Other: SD card capacity (bytes)
; u32 SD_GetCapacity (void)
; {
	.dbline 513
; 	u8 csd [16];
; 	unsigned long Capacity;
; 	unsigned long r1;
; 	unsigned long i;
; 	unsigned long temp;
; 	//u32 card_size;
; 	//u32 multiplier;
; 	
; 	// Get CSD information, if during the error, return 0
; 	if (SD_GetCSD (csd) != 0) 
	movw R16,R28
	subi R16,244  ; offset = 12
	sbci R17,255
	xcall _SD_GetCSD
	tst R16
	breq L121
X47:
	.dbline 514
; 	{	
	.dbline 515
; 		return 0;
	ldi R16,0
	ldi R17,0
	ldi R18,0
	ldi R19,0
	xjmp L120
L121:
	.dbline 519
; 	}
; 	
; 	// If the SDHC card, calculated in accordance with the following
; 	if ((csd [0] & 0xC0) == 0x40)
	ldd R24,y+12
	andi R24,192
	cpi R24,64
	breq X51
	xjmp L123
X51:
X48:
	.dbline 520
; 	{
	.dbline 521
; 		Capacity = ((u32) csd [8]) <<8;
	ldi R24,8
	ldi R25,0
	ldd R16,y+20
	clr R17
	clr R18
	clr R19
	st -y,R24
	xcall lsl32
	std y+28,R16
	std y+29,R17
	std y+30,R18
	std y+31,R19
	.dbline 522
; 		Capacity += (u32) csd [9] +1;
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+21
	clr R3
	clr R4
	clr R5
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	ldd R6,y+28
	ldd R7,y+29
	ldd R8,y+30
	ldd R9,y+31
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	std y+28,R6
	std y+29,R7
	std y+30,R8
	std y+31,R9
	.dbline 523
; 		Capacity = (Capacity) * 1024; // get number of sectors
	ldd R2,y+28
	ldd R3,y+29
	ldd R4,y+30
	ldd R5,y+31
	ldi R20,0
	ldi R21,4
	ldi R22,0
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	std y+28,R16
	std y+29,R17
	std y+30,R18
	std y+31,R19
	.dbline 524
; 		Capacity *= 512; // get number of bytes
	ldd R2,y+28
	ldd R3,y+29
	ldd R4,y+30
	ldd R5,y+31
	ldi R20,0
	ldi R21,2
	ldi R22,0
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	std y+28,R16
	std y+29,R17
	std y+30,R18
	std y+31,R19
	.dbline 527
; 
; 		// usart0_puts("SD_GetCapacity case 1\r\n");
; 	}
	xjmp L124
L123:
	.dbline 529
; 	else
; 	{
	.dbline 545
; 
; 
; 
; 
; #ifdef MMC_DBG
; 		int j;
; 
; 		for(j=0;j<16;j++)
; 			usart0_format_puts("%x\r\n", csd[j]);
; #endif		
; 		
; 
; 
; 
; 
; 		i = csd [6] &0x03;
	ldd R24,y+18
	clr R25
	andi R24,3
	andi R25,0
	movw R2,R24
	clr R4
	sbrc R3,7
	com R4
	clr R5
	sbrc R4,7
	com R5
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	.dbline 547
; 		//usart0_format_puts("\r\ni=%x", i);
; 		i <<= 8;		
	ldi R24,8
	ldi R25,0
	ldd R16,y+0
	ldd R17,y+1
	ldd R18,y+2
	ldd R19,y+3
	st -y,R24
	xcall lsl32
	std y+0,R16
	std y+1,R17
	std y+2,R18
	std y+3,R19
	.dbline 549
; 		//usart0_format_puts("\r\ni=%x", i);
; 		i += csd [7];
	ldd R2,y+19
	clr R3
	clr R4
	clr R5
	ldd R6,y+0
	ldd R7,y+1
	ldd R8,y+2
	ldd R9,y+3
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	std y+0,R6
	std y+1,R7
	std y+2,R8
	std y+3,R9
	.dbline 551
; 		//usart0_format_puts("\r\ni=%x", i);
; 		i <<= 2;
	ldi R24,2
	ldi R25,0
	ldd R16,y+0
	ldd R17,y+1
	ldd R18,y+2
	ldd R19,y+3
	st -y,R24
	xcall lsl32
	std y+0,R16
	std y+1,R17
	std y+2,R18
	std y+3,R19
	.dbline 553
; 		//usart0_format_puts("\r\ni=%x", i);
; 		i += ((csd [8] & 0xc0)>> 6);
	ldi R18,6
	ldi R19,0
	ldd R16,y+20
	clr R17
	andi R16,192
	andi R17,0
	xcall asr16
	movw R2,R16
	clr R4
	sbrc R3,7
	com R4
	clr R5
	sbrc R4,7
	com R5
	ldd R6,y+0
	ldd R7,y+1
	ldd R8,y+2
	ldd R9,y+3
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	std y+0,R6
	std y+1,R7
	std y+2,R8
	std y+3,R9
	.dbline 558
; 		//usart0_format_puts("\r\ni=%x", i);
; 	
; 		
; 		// C_SIZE_MULT
; 		r1 = csd [9] &0x03;
	ldd R24,y+21
	clr R25
	andi R24,3
	andi R25,0
	movw R2,R24
	clr R4
	sbrc R3,7
	com R4
	clr R5
	sbrc R4,7
	com R5
	std y+4,R2
	std y+5,R3
	std y+6,R4
	std y+7,R5
	.dbline 560
; 		//usart0_format_puts("\r\n1i=%x", i);
; 		r1 <<= 1;
	ldd R2,y+4
	ldd R3,y+5
	ldd R4,y+6
	ldd R5,y+7
	lsl R2
	rol R3
	rol R4
	rol R5
	std y+4,R2
	std y+5,R3
	std y+6,R4
	std y+7,R5
	.dbline 562
; 		//usart0_format_puts("\r\n2i=%x", i);
; 		r1 += ((csd [10] & 0x80)>> 7);
	ldi R18,7
	ldi R19,0
	ldd R16,y+22
	clr R17
	andi R16,128
	andi R17,0
	xcall asr16
	movw R2,R16
	clr R4
	sbrc R3,7
	com R4
	clr R5
	sbrc R4,7
	com R5
	ldd R6,y+4
	ldd R7,y+5
	ldd R8,y+6
	ldd R9,y+7
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	std y+4,R6
	std y+5,R7
	std y+6,R8
	std y+7,R9
	.dbline 564
; 		//usart0_format_puts("\r\n3i=%x", i);
; 		r1 += 2; // BLOCKNR
	ldi R20,2
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+4
	ldd R3,y+5
	ldd R4,y+6
	ldd R5,y+7
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	std y+4,R2
	std y+5,R3
	std y+6,R4
	std y+7,R5
	.dbline 566
; 		//usart0_format_puts("\r\n4i=%x", i);
; 		temp = 1;
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	std y+8,R20
	std y+9,R21
	std y+10,R22
	std y+11,R23
	xjmp L133
L132:
	.dbline 570
; 		//usart0_format_puts("\r\n5i=%x", i);
; 		
; 		while (r1)
; 		{
	.dbline 571
; 			temp *= 2;
	ldd R2,y+8
	ldd R3,y+9
	ldd R4,y+10
	ldd R5,y+11
	ldi R20,2
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	std y+8,R16
	std y+9,R17
	std y+10,R18
	std y+11,R19
	.dbline 572
; 			r1--;
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+4
	ldd R3,y+5
	ldd R4,y+6
	ldd R5,y+7
	sub R2,R20
	sbc R3,R21
	sbc R4,R22
	sbc R5,R23
	std y+4,R2
	std y+5,R3
	std y+6,R4
	std y+7,R5
	.dbline 573
; 		}
L133:
	.dbline 569
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+4
	ldd R3,y+5
	ldd R4,y+6
	ldd R5,y+7
	cp R2,R20
	cpc R3,R21
	cpc R4,R22
	cpc R5,R23
	brne L132
X49:
	.dbline 575
; 
; 		i++;
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+0
	ldd R3,y+1
	ldd R4,y+2
	ldd R5,y+3
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	.dbline 576
; 		Capacity = (u32)i * (u32)temp;
	ldd R2,y+8
	ldd R3,y+9
	ldd R4,y+10
	ldd R5,y+11
	ldd R16,y+0
	ldd R17,y+1
	ldd R18,y+2
	ldd R19,y+3
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32u
	std y+28,R16
	std y+29,R17
	std y+30,R18
	std y+31,R19
	.dbline 580
; 
; 	
; 		// READ_BL_LEN
; 		i = csd [5] &0x0f;
	ldd R24,y+17
	clr R25
	andi R24,15
	andi R25,0
	movw R2,R24
	clr R4
	sbrc R3,7
	com R4
	clr R5
	sbrc R4,7
	com R5
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	.dbline 583
; 		
; 		// BLOCK_LEN
; 		temp = 1;
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	std y+8,R20
	std y+9,R21
	std y+10,R22
	std y+11,R23
	xjmp L137
L136:
	.dbline 586
; 		
; 		while (i)
; 		{
	.dbline 587
; 			temp *= 2;
	ldd R2,y+8
	ldd R3,y+9
	ldd R4,y+10
	ldd R5,y+11
	ldi R20,2
	ldi R21,0
	ldi R22,0
	ldi R23,0
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	movw R16,R20
	movw R18,R22
	xcall empy32u
	std y+8,R16
	std y+9,R17
	std y+10,R18
	std y+11,R19
	.dbline 588
; 			i--;
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+0
	ldd R3,y+1
	ldd R4,y+2
	ldd R5,y+3
	sub R2,R20
	sbc R3,R21
	sbc R4,R22
	sbc R5,R23
	std y+0,R2
	std y+1,R3
	std y+2,R4
	std y+3,R5
	.dbline 589
; 		}
L137:
	.dbline 585
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+0
	ldd R3,y+1
	ldd R4,y+2
	ldd R5,y+3
	cp R2,R20
	cpc R3,R21
	cpc R4,R22
	cpc R5,R23
	brne L136
X50:
	.dbline 591
; 		
; 		Capacity *= (u32) temp; // in bytes
	ldd R2,y+8
	ldd R3,y+9
	ldd R4,y+10
	ldd R5,y+11
	ldd R16,y+28
	ldd R17,y+29
	ldd R18,y+30
	ldd R19,y+31
	st -y,R5
	st -y,R4
	st -y,R3
	st -y,R2
	xcall empy32u
	std y+28,R16
	std y+29,R17
	std y+30,R18
	std y+31,R19
	.dbline 593
; 
; 	}
L124:
	.dbline 595
; 
; 	return (u32) Capacity;
	ldd R16,y+28
	ldd R17,y+29
	ldd R18,y+30
	ldd R19,y+31
	.dbline -2
L120:
	.dbline 0 ; func end
	adiw R28,32
	xjmp pop_xgsetF000
	.dbsym l Capacity 28 l
	.dbsym l csd 12 A[16:16]c
	.dbsym l temp 8 l
	.dbsym l r1 4 l
	.dbsym l i 0 l
	.dbend
	.dbfunc e SD_ReadSingleBlock _SD_ReadSingleBlock fc
;             r1 -> R10
;         buffer -> y+9
;         sector -> y+5
	.even
_SD_ReadSingleBlock::
	xcall push_arg4
	st -y,R10
	st -y,R11
	sbiw R28,3
	.dbline -1
	.dbline 604
; }
; 
; // Read a block SD card
; // Input: u32 sector to take the address (sector value, non-physical address)
; // U8 * buffer data storage location (size at least 512byte)
; // Return value: 0: Success
; // Other: failure
; u8 SD_ReadSingleBlock (u32 sector, u8 * buffer)
; {
	.dbline 611
; 	u8 r1;
; 	
; 	// Set to high-speed mode
; 	// bsp_set_spi_speed(SPI_SPEED_4);
; 	
; 	// If it is not SDHC, given that the sector address, convert it into a byte address
; 	if (SD_Type != SD_TYPE_V2HC)
	lds R24,_SD_Type
	cpi R24,4
	breq L140
X52:
	.dbline 612
; 	{
	.dbline 613
; 	    sector = sector <<9;
	ldi R24,9
	ldi R25,0
	ldd R16,y+5
	ldd R17,y+6
	ldd R18,y+7
	ldd R19,y+8
	st -y,R24
	xcall lsl32
	std y+5,R16
	std y+6,R17
	std y+7,R18
	std y+8,R19
	.dbline 614
; 	}
L140:
	.dbline 616
; 	
; 	r1 = SD_SendCommand (CMD17, sector, 0); // read command
	clr R2
	std y+2,R2
	ldd R2,y+5
	ldd R3,y+6
	ldd R4,y+7
	ldd R5,y+8
	std y+0,R4
	std y+1,R5
	movw R18,R2
	ldi R16,17
	xcall _SD_SendCommand
	mov R10,R16
	.dbline 618
; 	
; 	if (r1 != 0x00) return r1;
	tst R16
	breq L142
X53:
	.dbline 618
	xjmp L139
L142:
	.dbline 620
; 	
; 	r1 = SD_ReceiveData (buffer, 512, RELEASE);
	ldi R24,1
	std y+0,R24
	ldi R18,512
	ldi R19,2
	ldd R16,y+9
	ldd R17,y+10
	xcall _SD_ReceiveData
	mov R10,R16
	.dbline 621
; 	if (r1 != 0) 
	tst R16
	breq L144
X54:
	.dbline 622
; 		return r1; // read data error!
	xjmp L139
L144:
	.dbline 624
; 	else 
; 		return 0;
	clr R16
	.dbline -2
L139:
	.dbline 0 ; func end
	adiw R28,3
	ld R11,y+
	ld R10,y+
	adiw R28,4
	ret
	.dbsym r r1 10 c
	.dbsym l buffer 9 pc
	.dbsym l sector 5 l
	.dbend
	.dbfunc e MSD_WriteBuffer _MSD_WriteBuffer fc
;     NbrOfBlock -> y+15
;             r1 -> R12
;         Offset -> y+11
;         sector -> y+7
;              i -> y+3
; NumByteToWrite -> y+35
;      WriteAddr -> y+31
;        pBuffer -> R10,R11
	.even
_MSD_WriteBuffer::
	st -y,r19
	st -y,r18
	xcall push_xgsetF03C
	movw R10,R16
	sbiw R28,23
	.dbline -1
	.dbline 638
; }
; //////////////////////////// Function of the following two required 
; /////////// USB reader //////////////
; // Define block size SD card
; #define BLOCK_SIZE 512
; 
; // Write MSD / SD data
; // PBuffer: Data Storage
; // ReadAddr: writing the first address
; // NumByteToRead: number of bytes to write
; // Return value: 0, write to complete
; // Otherwise, write failure
; u8 MSD_WriteBuffer (u8 * pBuffer, u32 WriteAddr, u32 NumByteToWrite)
; {
	.dbline 639
; 	u32 i, NbrOfBlock = 0, Offset = 0;
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	std y+15,R20
	std y+16,R21
	std y+17,R22
	std y+18,R23
	.dbline 639
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	std y+11,R20
	std y+12,R21
	std y+13,R22
	std y+14,R23
	.dbline 643
; 	u32 sector;
; 	u8 r1;
; 	
; 	NbrOfBlock = NumByteToWrite / BLOCK_SIZE; // get the number of blocks to be written
	ldi R24,9
	ldi R25,0
	ldd R16,y+35
	ldd R17,y+36
	ldd R18,y+37
	ldd R19,y+38
	st -y,R24
	xcall lsr32
	std y+15,R16
	std y+16,R17
	std y+17,R18
	std y+18,R19
	.dbline 644
; 	MSD_CS_ENABLE();
	cbi 0x18,0
	xjmp L148
L147:
	.dbline 647
; 	
; 	while (NbrOfBlock--) // write a sector
; 	{
	.dbline 648
; 		sector = WriteAddr + Offset;
	ldd R2,y+11
	ldd R3,y+12
	ldd R4,y+13
	ldd R5,y+14
	ldd R6,y+31
	ldd R7,y+32
	ldd R8,y+33
	ldd R9,y+34
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	std y+7,R6
	std y+8,R7
	std y+9,R8
	std y+10,R9
	.dbline 649
; 		if (SD_Type == SD_TYPE_V2HC) sector >>= 9; // perform the reverse operation and common action
	lds R24,_SD_Type
	cpi R24,4
	brne L150
X55:
	.dbline 649
	ldi R24,9
	ldi R25,0
	ldd R16,y+7
	ldd R17,y+8
	ldd R18,y+9
	ldd R19,y+10
	st -y,R24
	xcall lsr32
	std y+7,R16
	std y+8,R17
	std y+9,R18
	std y+10,R19
L150:
	.dbline 651
; 		
; 		r1 = SD_SendCommand_NoDeassert (CMD24, sector, 0xff); // write command
	ldi R24,255
	std y+2,R24
	ldd R2,y+7
	ldd R3,y+8
	ldd R4,y+9
	ldd R5,y+10
	std y+0,R4
	std y+1,R5
	movw R18,R2
	ldi R16,24
	xcall _SD_SendCommand_NoDeassert
	mov R12,R16
	.dbline 652
; 		if (r1)
	tst R16
	breq L152
X56:
	.dbline 653
; 		{
	.dbline 654
; 			MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 655
; 			return 1; // response is not correct, a direct return
	ldi R16,1
	xjmp L146
L152:
	.dbline 658
; 		}
; 		
; 		bsp_readwritebyte_spi (0xFE); // put initial token 0xFE
	ldi R16,254
	xcall _bsp_readwritebyte_spi
	.dbline 661
; 		
; 		// Put data in a sector
; 		for (i = 0; i <512; i++) 
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	std y+3,R20
	std y+4,R21
	std y+5,R22
	std y+6,R23
	xjmp L157
L154:
	.dbline 662
; 			bsp_readwritebyte_spi (*pBuffer++);
	movw R30,R10
	ld R16,Z+
	movw R10,R30
	xcall _bsp_readwritebyte_spi
L155:
	.dbline 661
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+3
	ldd R3,y+4
	ldd R4,y+5
	ldd R5,y+6
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	std y+3,R2
	std y+4,R3
	std y+5,R4
	std y+6,R5
L157:
	.dbline 661
	ldi R20,0
	ldi R21,2
	ldi R22,0
	ldi R23,0
	ldd R2,y+3
	ldd R3,y+4
	ldd R4,y+5
	ldd R5,y+6
	cp R2,R20
	cpc R3,R21
	cpc R4,R22
	cpc R5,R23
	brlo L154
X57:
	.dbline 665
; 		
; 		// Send the dummy CRC Byte 2
; 		bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 666
; 		bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 668
; 		
; 		if (SD_WaitDataReady ())// SD card data is written to wait for the completion
	xcall _SD_WaitDataReady
	tst R16
	breq L158
X58:
	.dbline 669
; 		{
	.dbline 670
; 			MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 671
; 			return 2;
	ldi R16,2
	xjmp L146
L158:
	.dbline 674
; 		}
; 		
; 		Offset += 512;
	ldi R20,0
	ldi R21,2
	ldi R22,0
	ldi R23,0
	ldd R2,y+11
	ldd R3,y+12
	ldd R4,y+13
	ldd R5,y+14
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	std y+11,R2
	std y+12,R3
	std y+13,R4
	std y+14,R5
	.dbline 675
; 	}
L148:
	.dbline 646
	ldd R2,y+15
	ldd R3,y+16
	ldd R4,y+17
	ldd R5,y+18
	std y+19,R2
	std y+20,R3
	std y+21,R4
	std y+22,R5
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+19
	ldd R3,y+20
	ldd R4,y+21
	ldd R5,y+22
	sub R2,R20
	sbc R3,R21
	sbc R4,R22
	sbc R5,R23
	std y+15,R2
	std y+16,R3
	std y+17,R4
	std y+18,R5
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+19
	ldd R3,y+20
	ldd R4,y+21
	ldd R5,y+22
	cp R2,R20
	cpc R3,R21
	cpc R4,R22
	cpc R5,R23
	breq X60
	xjmp L147
X60:
X59:
	.dbline 678
; 	
; 	// Write completed, set to 1 chip select	
; 	MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 679
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 681
; 	
; 	return 0;
	clr R16
	.dbline -2
L146:
	.dbline 0 ; func end
	adiw R28,23
	xcall pop_xgsetF03C
	adiw R28,2
	ret
	.dbsym l NbrOfBlock 15 l
	.dbsym r r1 12 c
	.dbsym l Offset 11 l
	.dbsym l sector 7 l
	.dbsym l i 3 l
	.dbsym l NumByteToWrite 35 l
	.dbsym l WriteAddr 31 l
	.dbsym r pBuffer 10 pc
	.dbend
	.dbfunc e MSD_ReadBuffer _MSD_ReadBuffer fc
;     NbrOfBlock -> y+11
;         Offset -> y+7
;         sector -> y+3
;             r1 -> R12
;  NumByteToRead -> y+31
;       ReadAddr -> y+27
;        pBuffer -> R10,R11
	.even
_MSD_ReadBuffer::
	st -y,r19
	st -y,r18
	xcall push_xgsetF03C
	movw R10,R16
	sbiw R28,19
	.dbline -1
	.dbline 691
; 	
; }
; // Read the MSD / SD data
; // PBuffer: Data Storage
; // ReadAddr: Read the first address
; // NumByteToRead: number of bytes to read
; // Return value: 0, read out the complete
; // Others, read failure
; u8 MSD_ReadBuffer (u8 * pBuffer, u32 ReadAddr, u32 NumByteToRead)
; {
	.dbline 692
; 	u32 NbrOfBlock = 0, Offset = 0;
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	std y+11,R20
	std y+12,R21
	std y+13,R22
	std y+14,R23
	.dbline 692
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	std y+7,R20
	std y+8,R21
	std y+9,R22
	std y+10,R23
	.dbline 693
; 	u32 sector = 0;
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	std y+3,R20
	std y+4,R21
	std y+5,R22
	std y+6,R23
	.dbline 694
; 	u8 r1 = 0;
	clr R12
	.dbline 696
; 	
; 	NbrOfBlock = NumByteToRead / BLOCK_SIZE;
	ldi R24,9
	ldi R25,0
	ldd R16,y+31
	ldd R17,y+32
	ldd R18,y+33
	ldd R19,y+34
	st -y,R24
	xcall lsr32
	std y+11,R16
	std y+12,R17
	std y+13,R18
	std y+14,R19
	.dbline 698
; 	
; 	MSD_CS_ENABLE();
	cbi 0x18,0
	xjmp L162
L161:
	.dbline 701
; 	
; 	while (NbrOfBlock--)
; 	{
	.dbline 702
; 		sector = ReadAddr + Offset;
	ldd R2,y+7
	ldd R3,y+8
	ldd R4,y+9
	ldd R5,y+10
	ldd R6,y+27
	ldd R7,y+28
	ldd R8,y+29
	ldd R9,y+30
	add R6,R2
	adc R7,R3
	adc R8,R4
	adc R9,R5
	std y+3,R6
	std y+4,R7
	std y+5,R8
	std y+6,R9
	.dbline 703
; 		if (SD_Type == SD_TYPE_V2HC) 
	lds R24,_SD_Type
	cpi R24,4
	brne L164
X61:
	.dbline 704
; 			sector >>= 9; // perform the reverse operation and common action
	ldi R24,9
	ldi R25,0
	ldd R16,y+3
	ldd R17,y+4
	ldd R18,y+5
	ldd R19,y+6
	st -y,R24
	xcall lsr32
	std y+3,R16
	std y+4,R17
	std y+5,R18
	std y+6,R19
L164:
	.dbline 706
; 			
; 		r1 = SD_SendCommand_NoDeassert (CMD17, sector, 0xff); // read command
	ldi R24,255
	std y+2,R24
	ldd R2,y+3
	ldd R3,y+4
	ldd R4,y+5
	ldd R5,y+6
	std y+0,R4
	std y+1,R5
	movw R18,R2
	ldi R16,17
	xcall _SD_SendCommand_NoDeassert
	mov R12,R16
	.dbline 707
; 		if (r1) // command to send an error
	tst R16
	breq L166
X62:
	.dbline 708
; 		{
	.dbline 709
; 			MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 710
; 			return r1;
	xjmp L160
L166:
	.dbline 713
; 		}
; 		
; 		r1 = SD_ReceiveData (pBuffer, 512, RELEASE);
	ldi R24,1
	std y+0,R24
	ldi R18,512
	ldi R19,2
	movw R16,R10
	xcall _SD_ReceiveData
	mov R12,R16
	.dbline 714
; 		if (r1) // reading error
	tst R16
	breq L168
X63:
	.dbline 715
; 		{
	.dbline 716
; 			MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 717
; 			return r1;
	xjmp L160
L168:
	.dbline 720
; 		}
; 		
; 		pBuffer += 512;
	movw R24,R10
	subi R24,0  ; offset = 512
	sbci R25,254
	movw R10,R24
	.dbline 721
; 		Offset += 512;
	ldi R20,0
	ldi R21,2
	ldi R22,0
	ldi R23,0
	ldd R2,y+7
	ldd R3,y+8
	ldd R4,y+9
	ldd R5,y+10
	add R2,R20
	adc R3,R21
	adc R4,R22
	adc R5,R23
	std y+7,R2
	std y+8,R3
	std y+9,R4
	std y+10,R5
	.dbline 722
; 	}
L162:
	.dbline 700
	ldd R2,y+11
	ldd R3,y+12
	ldd R4,y+13
	ldd R5,y+14
	std y+15,R2
	std y+16,R3
	std y+17,R4
	std y+18,R5
	ldi R20,1
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+15
	ldd R3,y+16
	ldd R4,y+17
	ldd R5,y+18
	sub R2,R20
	sbc R3,R21
	sbc R4,R22
	sbc R5,R23
	std y+11,R2
	std y+12,R3
	std y+13,R4
	std y+14,R5
	ldi R20,0
	ldi R21,0
	ldi R22,0
	ldi R23,0
	ldd R2,y+15
	ldd R3,y+16
	ldd R4,y+17
	ldd R5,y+18
	cp R2,R20
	cpc R3,R21
	cpc R4,R22
	cpc R5,R23
	breq X65
	xjmp L161
X65:
X64:
	.dbline 724
; 	
; 	MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 725
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 727
; 	
; 	return 0;
	clr R16
	.dbline -2
L160:
	.dbline 0 ; func end
	adiw R28,19
	xcall pop_xgsetF03C
	adiw R28,2
	ret
	.dbsym l NbrOfBlock 11 l
	.dbsym l Offset 7 l
	.dbsym l sector 3 l
	.dbsym r r1 12 c
	.dbsym l NumByteToRead 31 l
	.dbsym l ReadAddr 27 l
	.dbsym r pBuffer 10 pc
	.dbend
	.dbfunc e SD_WriteSingleBlock _SD_WriteSingleBlock fc
;             r1 -> R20
;          retry -> R20,R21
;              i -> R22,R23
;           data -> R10,R11
;         sector -> y+9
	.even
_SD_WriteSingleBlock::
	xcall push_arg4
	xcall push_xgsetF00C
	sbiw R28,3
	ldd R10,y+13
	ldd R11,y+14
	.dbline -1
	.dbline 736
; }
; //////////////////////////////////////////////////////////////////////////
; // Write SD card, a block (not actually tested)
; // Input: u32 sector sector address (sector value, non-physical address)
; // U8 * buffer data storage location (size at least 512byte)
; // Return value: 0: Success
; // Other: failure
; u8 SD_WriteSingleBlock (u32 sector, const u8 * data)
; {
	.dbline 745
; 	u8 r1;
; 	u16 i;
; 	u16 retry;
; 
; 	// Set to high-speed mode
; 	// SPIx_SetSpeed(SPI_SPEED_HIGH);
; 	
; 	// If it is not SDHC, given that the sector address, convert it into a byte address
; 	if (SD_Type != SD_TYPE_V2HC)
	lds R24,_SD_Type
	cpi R24,4
	breq L171
X66:
	.dbline 746
; 	{
	.dbline 747
; 		sector = sector <<9;
	ldi R24,9
	ldi R25,0
	ldd R16,y+9
	ldd R17,y+10
	ldd R18,y+11
	ldd R19,y+12
	st -y,R24
	xcall lsl32
	std y+9,R16
	std y+10,R17
	std y+11,R18
	std y+12,R19
	.dbline 748
; 	}
L171:
	.dbline 750
; 	
; 	r1 = SD_SendCommand (CMD24, sector, 0x00);
	clr R2
	std y+2,R2
	ldd R2,y+9
	ldd R3,y+10
	ldd R4,y+11
	ldd R5,y+12
	std y+0,R4
	std y+1,R5
	movw R18,R2
	ldi R16,24
	xcall _SD_SendCommand
	mov R20,R16
	.dbline 751
; 	if (r1 != 0x00)
	tst R16
	breq L173
X67:
	.dbline 752
; 	{
	.dbline 753
; 		return r1; // response is not correct, a direct return
	xjmp L170
L173:
	.dbline 757
; 	}
; 
; 	// Start preparing data
; 	MSD_CS_ENABLE();
	cbi 0x18,0
	.dbline 759
; 	// First put three empty data, SD card ready to wait
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 760
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 761
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 763
; 	// Put initial token 0xFE
; 	bsp_readwritebyte_spi (0xFE);
	ldi R16,254
	xcall _bsp_readwritebyte_spi
	.dbline 766
; 
; 	// Put data in a sector
; 	for (i = 0; i <512; i++)
	clr R22
	clr R23
	xjmp L178
L175:
	.dbline 767
; 	{
	.dbline 768
; 		bsp_readwritebyte_spi (* data++);
	movw R2,R10
	movw R24,R2
	adiw R24,1
	movw R10,R24
	movw R30,R2
	lpm R16,Z
	xcall _bsp_readwritebyte_spi
	.dbline 769
; 	}
L176:
	.dbline 766
	subi R22,255  ; offset = 1
	sbci R23,255
L178:
	.dbline 766
	cpi R22,0
	ldi R30,2
	cpc R23,R30
	brlo L175
X68:
	.dbline 772
; 	
; 	// Send a dummy CRC Byte 2
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 773
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 776
; 
; 	// Wait for answer SD Card
; 	r1 = bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	mov R20,R10
	.dbline 777
; 	if ((r1 & 0x1F) != 0x05)
	mov R24,R20
	andi R24,31
	cpi R24,5
	breq L179
X69:
	.dbline 778
; 	{
	.dbline 779
; 	    MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 780
; 	    return r1;
	xjmp L170
L179:
	.dbline 784
; 	}
; 
; 	// Wait operation is completed
; 	retry = 0;
	clr R20
	clr R21
	xjmp L182
L181:
	.dbline 786
; 	while ( !bsp_readwritebyte_spi (0xff))
; 	{
	.dbline 787
; 	    retry++;
	subi R20,255  ; offset = 1
	sbci R21,255
	.dbline 788
; 	    if (retry> 0xfffe) // if not done for a long time to write, error exit
	ldi R24,65534
	ldi R25,255
	cp R24,R20
	cpc R25,R21
	brsh L184
X70:
	.dbline 789
; 	    {
	.dbline 790
; 	        MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 791
; 	        return 1; // write timeout return 1
	ldi R16,1
	xjmp L170
L184:
	.dbline 793
; 	    }
; 	}
L182:
	.dbline 785
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	tst R16
	breq L181
X71:
	.dbline 795
; 	// Write completed, set to 1 chip select
; 	MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 796
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 798
; 
; 	return 0;
	clr R16
	.dbline -2
L170:
	.dbline 0 ; func end
	adiw R28,3
	xcall pop_xgsetF00C
	adiw R28,4
	ret
	.dbsym r r1 20 c
	.dbsym r retry 20 i
	.dbsym r i 22 i
	.dbsym r data 10 pkc
	.dbsym l sector 9 l
	.dbend
	.dbfunc e SD_ReadMultiBlock _SD_ReadMultiBlock fc
;             r1 -> R10
;          count -> R20
;         buffer -> R22,R23
;         sector -> y+9
	.even
_SD_ReadMultiBlock::
	xcall push_arg4
	xcall push_xgsetF00C
	sbiw R28,3
	ldd R22,y+13
	ldd R23,y+14
	ldd R20,y+15
	.dbline -1
	.dbline 808
; }
; 
; // Read more than one SD card block (actually tested)
; // Input: u32 sector sector address (sector value, non-physical address)
; // U8 * buffer data storage location (size at least 512byte)
; // U8 count one continuous block read count
; // Return value: 0: Success
; // Other: failure
; u8 SD_ReadMultiBlock (u32 sector, u8 * buffer, u8 count)
; {
	.dbline 814
;     u8 r1;
; 	
; 	// SPIx_SetSpeed(SPI_SPEED_HIGH); // set to high-speed mode
; 	
; 	// If it is not SDHC, the sector addresses turn into a byte address
; 	if (SD_Type != SD_TYPE_V2HC) 
	lds R24,_SD_Type
	cpi R24,4
	breq L187
X72:
	.dbline 815
; 		sector = sector <<9;
	ldi R24,9
	ldi R25,0
	ldd R16,y+9
	ldd R17,y+10
	ldd R18,y+11
	ldd R19,y+12
	st -y,R24
	xcall lsl32
	std y+9,R16
	std y+10,R17
	std y+11,R18
	std y+12,R19
L187:
	.dbline 819
; 
; 	// SD_WaitDataReady ();
; 	// Read multi-block commands issued
; 	r1 = SD_SendCommand (CMD18, sector, 0); // read command
	clr R2
	std y+2,R2
	ldd R2,y+9
	ldd R3,y+10
	ldd R4,y+11
	ldd R5,y+12
	std y+0,R4
	std y+1,R5
	movw R18,R2
	ldi R16,18
	xcall _SD_SendCommand
	mov R10,R16
	.dbline 820
; 	if (r1 != 0x00) return r1;
	tst R16
	breq L189
X73:
	.dbline 820
	xjmp L186
L189:
L191:
	.dbline 823
; 	
; 	do // Start receiving data
; 	{
	.dbline 824
; 	    if (SD_ReceiveData (buffer, 512, NO_RELEASE) != 0x00) break;
	clr R2
	std y+0,R2
	ldi R18,512
	ldi R19,2
	movw R16,R22
	xcall _SD_ReceiveData
	tst R16
	breq L194
X74:
	.dbline 824
	xjmp L193
L194:
	.dbline 825
; 	    buffer += 512;
	subi R22,0  ; offset = 512
	sbci R23,254
	.dbline 826
; 	} while (--count);
L192:
	.dbline 826
	mov R24,R20
	subi R24,1
	mov R10,R24
	mov R20,R24
	tst R24
	brne L191
X75:
L193:
	.dbline 829
; 	
; 	// All the transmission is completed, send the stop command
; 	SD_SendCommand (CMD12, 0, 0);
	clr R2
	std y+2,R2
	ldi R24,0
	ldi R25,0
	ldi R26,0
	ldi R27,0
	std y+0,R26
	std y+1,R27
	movw R18,R24
	ldi R16,12
	xcall _SD_SendCommand
	.dbline 832
; 	
; 	// Release bus
; 	MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 833
; 	bsp_readwritebyte_spi (0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 835
; 	
; 	if (count != 0) 
	tst R20
	breq L196
X76:
	.dbline 836
; 		return count; // end if not passed, return the remaining number of
	mov R16,R20
	xjmp L186
L196:
	.dbline 838
; 	else 
; 		return 0;
	clr R16
	.dbline -2
L186:
	.dbline 0 ; func end
	adiw R28,3
	xcall pop_xgsetF00C
	adiw R28,4
	ret
	.dbsym r r1 10 c
	.dbsym r count 20 c
	.dbsym r buffer 22 pc
	.dbsym l sector 9 l
	.dbend
	.dbfunc e SD_WriteMultiBlock _SD_WriteMultiBlock fc
;             r1 -> R22
;              i -> R10,R11
;          count -> R20
;           data -> R12,R13
;         sector -> y+13
	.even
_SD_WriteMultiBlock::
	xcall push_arg4
	xcall push_xgsetF0FC
	sbiw R28,3
	ldd R12,y+17
	ldd R13,y+18
	ldd R20,y+19
	.dbline -1
	.dbline 848
; 	
; }
; // Write SD card, N-block (not actually tested)
; // Input: u32 sector sector address (sector value, non-physical address)
; // U8 * buffer data storage location (size at least 512byte)
; // U8 count the number of write block
; // Return value: 0: Success
; // Other: failure
; u8 SD_WriteMultiBlock (u32 sector, const u8 * data, u8 count)
; {
	.dbline 854
; 	u8 r1;
; 	u16 i;
; 
; 	// SPIx_SetSpeed (SPI_SPEED_HIGH); // set to high-speed mode
; 	
; 	if (SD_Type != SD_TYPE_V2HC) 
	lds R24,_SD_Type
	cpi R24,4
	breq L199
X77:
	.dbline 855
; 		sector = sector <<9; // If it is not SDHC, given that the sector address, convert it to byte address
	ldi R24,9
	ldi R25,0
	ldd R16,y+13
	ldd R17,y+14
	ldd R18,y+15
	ldd R19,y+16
	st -y,R24
	xcall lsl32
	std y+13,R16
	std y+14,R17
	std y+15,R18
	std y+16,R19
L199:
	.dbline 856
; 	if (SD_Type != SD_TYPE_MMC) 
	lds R2,_SD_Type
	tst R2
	breq L201
X78:
	.dbline 857
; 		r1 = SD_SendCommand (ACMD23, count, 0x00); // If the target card is not the MMC card, enable the command to enable pre-erase ACMD23
	clr R2
	std y+2,R2
	mov R2,R20
	clr R3
	clr R4
	clr R5
	std y+0,R4
	std y+1,R5
	movw R18,R2
	ldi R16,23
	xcall _SD_SendCommand
L201:
	.dbline 859
; 		
; 	r1 = SD_SendCommand (CMD25, sector, 0x00); // send multi-block write command
	clr R2
	std y+2,R2
	ldd R2,y+13
	ldd R3,y+14
	ldd R4,y+15
	ldd R5,y+16
	std y+0,R4
	std y+1,R5
	movw R18,R2
	ldi R16,25
	xcall _SD_SendCommand
	mov R22,R16
	.dbline 860
; 	if (r1 != 0x00) 
	tst R16
	breq L203
X79:
	.dbline 861
; 		return r1; // response is not correct, a direct return
	xjmp L198
L203:
	.dbline 863
; 		
; 	MSD_CS_ENABLE(); // start preparing data
	cbi 0x18,0
	.dbline 865
; 	
; 	bsp_readwritebyte_spi (0xff); // first put three empty data, SD card ready to wait
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 866
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
L205:
	.dbline 870
; 	//-------- The following is written by N-loop part of the sector
; 	
; 	do
; 	{
	.dbline 872
; 		// Put the start token that is a multi-block write 0xFC
; 		bsp_readwritebyte_spi (0xFC);
	ldi R16,252
	xcall _bsp_readwritebyte_spi
	.dbline 874
; 		// Put data in a sector
; 		for (i = 0; i <512; i++)
	clr R10
	clr R11
	xjmp L211
L208:
	.dbline 875
; 		{
	.dbline 876
; 			bsp_readwritebyte_spi (* data++);
	movw R14,R12
	movw R24,R14
	adiw R24,1
	movw R12,R24
	movw R30,R14
	lpm R16,Z
	xcall _bsp_readwritebyte_spi
	.dbline 877
; 		}
L209:
	.dbline 874
	movw R24,R10
	adiw R24,1
	movw R10,R24
L211:
	.dbline 874
	movw R24,R10
	cpi R24,0
	ldi R30,2
	cpc R25,R30
	brlo L208
X80:
	.dbline 879
; 		// Send a dummy CRC Byte 2
; 		bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 880
; 		bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 883
; 
; 		// Wait for answer SD Card
; 		r1 = bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	mov R22,R10
	.dbline 884
; 		if ((r1 & 0x1F) != 0x05)
	mov R24,R22
	andi R24,31
	cpi R24,5
	breq L212
X81:
	.dbline 885
; 		{
	.dbline 886
; 			MSD_CS_DISABLE(); // If the response is an error, then exit with error code
	sbi 0x18,0
	.dbline 887
; 			return r1;
	xjmp L198
L212:
	.dbline 890
; 		}
; 		// Wait for write to complete the SD card
; 		if (SD_WaitDataReady () == 1)
	xcall _SD_WaitDataReady
	mov R10,R16
	cpi R16,1
	brne L214
X82:
	.dbline 891
; 		{
	.dbline 892
; 			MSD_CS_DISABLE(); // wait for write to complete the SD card out, exit error
	sbi 0x18,0
	.dbline 893
; 			return 1;
	ldi R16,1
	xjmp L198
L214:
	.dbline 895
; 		}
; 	} while (--count); // completion of the sector data transfer
L206:
	.dbline 895
	mov R24,R20
	subi R24,1
	mov R10,R24
	mov R20,R24
	tst R24
	breq X86
	xjmp L205
X86:
X83:
	.dbline 898
; 	
; 	// Send end of the transmission token 0xFD
; 	r1 = bsp_readwritebyte_spi (0xFD);
	ldi R16,253
	xcall _bsp_readwritebyte_spi
	mov R10,R16
	mov R22,R10
	.dbline 899
; 	if (r1 == 0x00)
	tst R16
	brne L216
X84:
	.dbline 900
; 	{
	.dbline 901
; 		count = 0xfe;
	ldi R20,254
	.dbline 902
; 	}
L216:
	.dbline 904
; 	
; 	if (SD_WaitDataReady ()) // wait for ready
	xcall _SD_WaitDataReady
	mov R10,R16
	tst R16
	breq L218
X85:
	.dbline 905
; 	{
	.dbline 906
; 		MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 907
; 		return 1;
	ldi R16,1
	xjmp L198
L218:
	.dbline 910
; 	}
; 	// Write completed, set to 1 chip select
; 	MSD_CS_DISABLE();
	sbi 0x18,0
	.dbline 911
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 913
; 	
; 	return count; // return count value, if finished then count = 0, otherwise, count = 1
	mov R16,R20
	.dbline -2
L198:
	.dbline 0 ; func end
	adiw R28,3
	xcall pop_xgsetF0FC
	adiw R28,4
	ret
	.dbsym r r1 22 c
	.dbsym r i 10 i
	.dbsym r count 20 c
	.dbsym r data 12 pkc
	.dbsym l sector 13 l
	.dbend
	.dbfunc e SD_Read_Bytes _SD_Read_Bytes fc
;             r1 -> R14
;              i -> R20,R21
;          bytes -> y+19
;         offset -> R10,R11
;            buf -> R12,R13
;        address -> y+11
	.even
_SD_Read_Bytes::
	xcall push_arg4
	xcall push_xgset30FC
	sbiw R28,3
	ldd R12,y+15
	ldd R13,y+16
	ldd R10,y+17
	ldd R11,y+18
	.dbline -1
	.dbline 924
; 	
; }
; // In the specified sector, began to read out bytes from the offset byte
; // Input: u32 sector sector address (sector value, non-physical address)
; // U8 * buf data storage addresses (size <= 512byte)
; // U16 offset offset inside the sector
; // U16 bytes number of bytes to read
; // Return value: 0: Success
; // Other: failure
; u8 SD_Read_Bytes (unsigned long address, unsigned char * buf, unsigned int offset, unsigned int bytes)
; {
	.dbline 925
; 	u8 r1; u16 i = 0;
	clr R20
	clr R21
	.dbline 926
; 	r1 = SD_SendCommand (CMD17, address <<9,0); // send the Read Sector command
	clr R2
	std y+2,R2
	ldi R24,9
	ldi R25,0
	ldd R16,y+11
	ldd R17,y+12
	ldd R18,y+13
	ldd R19,y+14
	st -y,R24
	xcall lsl32
	std y+0,R18
	std y+1,R19
	movw R18,R16
	ldi R16,17
	xcall _SD_SendCommand
	mov R14,R16
	.dbline 928
; 	
; 	if (r1) 
	tst R16
	breq L221
X87:
	.dbline 929
; 		return r1; // response is not correct, a direct return
	xjmp L220
L221:
	.dbline 931
; 		
; 	MSD_CS_ENABLE(); // select the SD card
	cbi 0x18,0
	.dbline 933
; 	
; 	if (SD_GetResponse (0xFE)) // wait for data sent back to the starting SD card token 0xFE
	ldi R16,254
	xcall _SD_GetResponse
	tst R16
	breq L223
X88:
	.dbline 934
; 	{
	.dbline 935
; 		MSD_CS_DISABLE(); // close the SD card
	sbi 0x18,0
	.dbline 936
; 		return 1; // read failure
	ldi R16,1
	xjmp L220
L223:
	.dbline 939
; 	}
; 	
; 	for (i = 0; i <offset; i++) bsp_readwritebyte_spi (0xff); // skip the offset bits
	clr R20
	clr R21
	xjmp L228
L225:
	.dbline 939
	ldi R16,255
	xcall _bsp_readwritebyte_spi
L226:
	.dbline 939
	subi R20,255  ; offset = 1
	sbci R21,255
L228:
	.dbline 939
	cp R20,R10
	cpc R21,R11
	brlo L225
X89:
	.dbline 940
; 	for (; i <offset + bytes; i++) * buf++= bsp_readwritebyte_spi (0xff); // read the useful data
	xjmp L232
L229:
	.dbline 940
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R14,R16
	movw R30,R12
	st Z+,R14
	movw R12,R30
L230:
	.dbline 940
	subi R20,255  ; offset = 1
	sbci R21,255
L232:
	.dbline 940
	movw R2,R10
	ldd R0,y+19
	ldd R1,y+20
	add R2,R0
	adc R3,R1
	cp R20,R2
	cpc R21,R3
	brlo L229
X90:
	.dbline 941
; 	for (; i <512; i++) bsp_readwritebyte_spi (0xff); // read the remaining bytes
	xjmp L236
L233:
	.dbline 941
	ldi R16,255
	xcall _bsp_readwritebyte_spi
L234:
	.dbline 941
	subi R20,255  ; offset = 1
	sbci R21,255
L236:
	.dbline 941
	cpi R20,0
	ldi R30,2
	cpc R21,R30
	brlo L233
X91:
	.dbline 943
; 	
; 	bsp_readwritebyte_spi (0xff); // send the pseudo-code CRC
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 944
; 	bsp_readwritebyte_spi (0xff);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	.dbline 946
; 	
; 	MSD_CS_DISABLE(); // close the SD card
	sbi 0x18,0
	.dbline 948
; 	
; 	return 0;
	clr R16
	.dbline -2
L220:
	.dbline 0 ; func end
	adiw R28,3
	xcall pop_xgset30FC
	adiw R28,4
	ret
	.dbsym r r1 14 c
	.dbsym r i 20 i
	.dbsym l bytes 19 i
	.dbsym r offset 10 i
	.dbsym r buf 12 pc
	.dbsym l address 11 l
	.dbend
	.dbfunc e SD_WaitReady _SD_WaitReady fc
;          retry -> R20,R21
;             r1 -> R22
	.even
_SD_WaitReady::
	xcall push_xgsetF000
	.dbline -1
	.dbline 952
; }
; 
; u8 SD_WaitReady(void)
; {
	.dbline 955
;     u8 r1;
;     u16 retry;
;     retry = 0;
	clr R20
	clr R21
L238:
	.dbline 957
;     do
;     {
	.dbline 958
;         r1 = bsp_readwritebyte_spi(0xFF);
	ldi R16,255
	xcall _bsp_readwritebyte_spi
	mov R22,R16
	.dbline 959
;         if(retry==0xfffe)
	cpi R20,254
	ldi R30,255
	cpc R21,R30
	brne L241
X92:
	.dbline 960
;         {
	.dbline 961
;             return 1;
	ldi R16,1
	xjmp L237
L241:
	.dbline 963
;         }
;     }while(r1!=0xFF);
L239:
	.dbline 963
	cpi R22,255
	brne L238
X93:
	.dbline 965
; 
;     return 0;
	clr R16
	.dbline -2
L237:
	.dbline 0 ; func end
	xjmp pop_xgsetF000
	.dbsym r retry 20 i
	.dbsym r r1 22 c
	.dbend
; }
; 
; 
; 
; 
